package com.basic.business.order.controller;

import com.basic.business.order.domain.TOrdersStatus;
import com.basic.business.order.service.ITOrdersStatusService;
import com.basic.common.annotation.Log;
import com.basic.common.core.controller.BaseController;
import com.basic.common.core.domain.AjaxResult;
import com.basic.common.enums.BusinessType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 订单状态管理
 *
 * @author zhaoxy_jn@163.com
 */
@RestController
@RequestMapping("/business/ordersStatus")
public class TOrdersStatusController extends BaseController {

    @Resource
    private ITOrdersStatusService statusService;

    /**
     * 校验状态是MANUAL的订单平台单号是否重复
     */
    @PostMapping("/checkTidIsUnique")
    public AjaxResult checkTidIsUnique(@RequestBody List<TOrdersStatus> statusList, @RequestParam("oldPst") String oldPst)
    {
        return success(statusService.checkTidIsUnique(statusList, oldPst));
    }

    /**
     * 补全信息
     */
    @PostMapping("/getOrderStatusInfo")
    public AjaxResult getOrderStatusInfo(@RequestBody List<TOrdersStatus> statusList)
    {
        return success(statusService.getOrderStatusInfo(statusList));
    }

    /**
     * 更新订单信息
     */
    @Log(title = "订单状态", businessType = BusinessType.UPDATE)
    @PostMapping("/updateOrdersStatus")
    public AjaxResult updateOrdersStatus(@RequestBody List<TOrdersStatus> statusList)
    {
        statusService.updateOrdersStatus(statusList);
        return success();
    }

}
